﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using MyCommon;

namespace BussinessLayer
{
    public class LichSuBHBO : BaseBO
    {
        #region Singleton implemented
        private static LichSuBHBO _instance;
        private LichSuBHBO()
        {}
        public static LichSuBHBO getInstance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new LichSuBHBO();
                }
                return _instance;
            }
        }
#endregion

        public IEnumerable<LichSuBH> GetAllLichSuBH()
        {
            return _dao.LichSuBH.GetAllLichSuBH();
        }
        public LichSuBH GetLichSuBHById(int id)
        {
            return _dao.LichSuBH.GetLichSuBHById(id);
        }
        public bool UpdateLichSuBH(LichSuBH inLichSuBH)
        {
            return _dao.LichSuBH.UpdateLichSuBH(inLichSuBH);
        }
        public bool InsertLichSuBH(LichSuBH inLichSuBH)
        {
            return _dao.LichSuBH.InsertLichSuBH(inLichSuBH);
        }
        public ReturnValue<bool> DelLichSuBH(int id)
        {
            return _dao.LichSuBH.DelLichSuBH(id);
        }

        public ReturnValue<bool> IsCoQuyen(int inLichSuId, int inNhanVienId)
        {
            ReturnValue<bool> retValue = new ReturnValue<bool>(false, "");
            LichSuBH CurrentLichSu = LichSuBHBO.getInstance.GetLichSuBHById(inLichSuId);
            if (inNhanVienId == CurrentLichSu.NVThucHienId)
            {
                retValue.RetValue = true;
            }
            return retValue;
        }

        public LichSuBH GetLastRecord()
        {
            return _dao.LichSuBH.GetLastRecord();
        }

        public IEnumerable<LichSuBH> GetLichSuBHByPhien_ThietBiId(int inPhien_ThietBiBHId, MyCommon.LoaiLichSu inLoaiLichSu)
        {
            return _dao.LichSuBH.GetLichSuBHByPhien_ThietBiId(inPhien_ThietBiBHId, inLoaiLichSu);
        }
        public IEnumerable<LichSuBH> GetLichSuInListLoaiLichSu(int inPhien_ThietBiBHId, List<int> inListLoaiLichSuId)
        {
            return _dao.LichSuBH.GetLichSuInListLoaiLichSu(inPhien_ThietBiBHId, inListLoaiLichSuId);
        }
    }
}
